import { Injectable } from '@angular/core';
import {ExecActionInterface} from "./exec-action-interface";
import {ImageExifExecActionService} from "./image-exif-exec-action.service";
import {FileExecActionService} from "./file-exec-action.service";
import {MatchExecActionService} from "./match-exec-action.service";
import {InfoExtractExecActionService} from "./info-extract-exec-action.service";
import {ExecOneExecActionService} from "./exec-one-exec-action.service";

@Injectable({
  providedIn: 'root'
})
export class ExecActionMainService {

  execList: ExecActionInterface[] = []
  // execMap:any = {}
  constructor(
    private imgExif:ImageExifExecActionService,
    private copyFile:FileExecActionService,
    private match:MatchExecActionService,
    private extract:InfoExtractExecActionService,
    private execOne:ExecOneExecActionService

  ) {
    this.addExecAction(match)
    this.addExecAction(imgExif)
    this.addExecAction(copyFile)
    this.addExecAction(extract)
    this.addExecAction(execOne)
  }
  public addExecAction(exec:ExecActionInterface){
    this.execList.push(exec)
    // this.execMap[exec.code] = exec
  }
  public getExecAction(actionCode:string):ExecActionInterface | null{
    for (let exec of this.execList) {
      if (exec.code == actionCode){
        return exec;
      }
    }
    return  null;

  }
}
